﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SCCN.BLL;
using SCCN.Utility;
using SCCN.DAL;


public partial class Admin_ModifyCategory : ASPBaseClass
{
    CategoryBLL bllCategoryBLL = CategoryBLL.getInstance();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
        }
    }

    void Bind()
    {
        int Id = 0;
        int.TryParse(HttpHelper.GetParameters("Id", HttpHelper.MethodType.GET), out Id);
        SC_Category obj =  bllCategoryBLL.GetCategoryByID(Id);
        this.txtCategroyName.Text = obj.CategoryName;
        this.HId.Value = obj.Id.ToString();
    }

    /// <summary>
    /// 修改保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        SC_Category obj = new SC_Category();
        int Id = 0;
        int.TryParse(this.HId.Value, out Id);
        obj.Id = Id;
        obj.CategoryName = this.txtCategroyName.Text;
        obj.IsDelete = false;
        if (bllCategoryBLL.UpdateCategory(obj))
        {
            HttpHelper.Alert("保存成功！", Page);
        }
        else
        {
            HttpHelper.Alert("保存失败！", Page);
        }
    }
}